package com.ds.infrastructure.hyperspace.container.admin;

import com.ds.infrastructure.hyperspace.container.internal.NettyContainer;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.http.HttpClientCodec;

/**
 * @author  Weishaoying
 */
public class ConsoleClientChannelInitializer extends ChannelInitializer<Channel> {

    private final NettyContainer container;

    public ConsoleClientChannelInitializer(NettyContainer container) {
        this.container = container;
    }

    @Override
    protected void initChannel(Channel channel) throws Exception {
        ChannelPipeline channelPipeline = channel.pipeline();
        channelPipeline.addLast(new HttpClientCodec());
        channelPipeline.addLast(new ConsoleClientHandler(container));
    }
}
